home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
LANG
/
C
/
LIB
/
HASWIN
/
HASWIN3
/
_files
/
_haswin
/
TASK._c
< prev
next >
Wrap
Text File
|
1991-05-27
|
5KB
|
142 lines
/* > $.CLIB.HASWIN.C.task
*
* HASWIN Graphics Library
* =========================
*
* Copyright (C) H.A.Shaw 1990.
* Howard A. Shaw.
* The Unit for Space Sciences,
* Room 165,
* Physics Building,
* University of Kent at Canterbury.
* Canterbury.
* Kent. CT2 7NJ
* You may use and distribute this code freely, however please leave
* it alone. If you find bugs (and there will be many) please contact
* me and the master source can be modified. If you keep me informed
* of who you give copies of this to then I can get release upgrades
* to them.
*
* task control routines. The comments in this code talk about a
* linked list of tasks maintained by HASWIN to ease inter-process
* communications. This has become unnecessary since I don't do
* inter-process communications properly in this release of HASWIN.
* It all will be added later!
*/
#include "includes.h"
int haswin_gettaskid() {
if (!(haswin_flags & HASWIN_FLAGS_STARTED))
return(HASWIN_UNKNOWN);
return(haswin_taskid);
}
char *haswin_gettaskname() {
if (!(haswin_flags & HASWIN_FLAGS_STARTED))
return((char *)0);
return(haswin_taskname);
}
void haswin_taskclosedown() {
_kernel_swi_regs regs;
/* close the WIMP down */
if (haswin_flags & HASWIN_FLAGS_STARTED) {
if (haswin_taskid != HASWIN_UNKNOWN) {
regs.r[0] = haswin_taskid;
regs.r[1] = 'T' + ('A'<<8) + ('S'<<16) + ('K'<<24);
} else
regs.r[0] = regs.r[1] = 0;
haswin_swi(HASWIN_Closedown , ®s);
haswin_flags &= ~HASWIN_FLAGS_STARTED;
}
}
/*
* initialise the window managment system.
* First we start the WIMP and then generate the linked list of
* active tasks. This is maintained by the haswin_poll() routine
* as tasks enter and leave the system. The first task in the list
* is ourselves.
*/
int haswin_taskinitialise(char *name) {
_kernel_swi_regs regs;
/* start the HASWIN WIMP */
regs.r[0] = 200; /* we require WIMP version 2.00 or later */
if ((!name) || (name[0] == 0)) {
regs.r[1] = 0;
regs.r[2] = 0;
if (!haswin_swi(HASWIN_Initialise, ®s))
return(HASWIN_FALSE);
haswin_taskid = HASWIN_UNKNOWN;
strncpy(haswin_taskname, "Not a Task", TASK_MAXNAME);
} else {
regs.r[1] = 'T' + ('A'<<8) + ('S'<<16) + ('K'<<24);
regs.r[2] = (int)name;
if (!haswin_swi(HASWIN_Initialise, ®s))
return(HASWIN_FALSE);
haswin_taskid = regs.r[1];
strncpy(haswin_taskname, name, TASK_MAXNAME);
}
haswin_version = regs.r[0];
return(haswin_version);
}
/*
* Given a window handle find the task name of the owner of the window.
* return NULL on an error. We issue a TaskNameRq message to the Task
* Manager and then poll until we get a reply. haswin_poll() places
* the reply into the string "haswin_tasknameis" for us, which we then
* return.
*/
char *haswin_findtasknamewin(int win) {
buffer buff;
_kernel_swi_regs regs;
if (!win)
return(0);
buff.i[0] = 24;
buff.i[1] = 0;
buff.i[2] = 0;
buff.i[3] = 0;
buff.i[4] = MESSAGE_TaskNameRq;
buff.i[5] = win;
regs.r[0] = HASWIN_POLL_Message_Rec;
regs.r[1] = (int)&buff;
regs.r[2] = win;
regs.r[3] = -1;
haswin_swi(HASWIN_Send_message, ®s);
haswin_flags |= HASWIN_FLAGS_TASKIS;
while (haswin_flags & HASWIN_FLAGS_TASKIS)
haswin_poll();
return(haswin_tasknameis);
}
/*
* Given a window handle find the task id of the owner of the window.
* return HASWIN_UNKNOWN on an error. We issue a dummy message to
* the Task Manager to get the taskid back.
*/
int haswin_findtaskidwin(int win) {
buffer buff;
_kernel_swi_regs regs;
if (!win)
return(HASWIN_UNKNOWN);
buff.i[0] = 20;
buff.i[1] = 0;
buff.i[2] = 0;
buff.i[3] = 0;
buff.i[4] = 0;
regs.r[0] = HASWIN_POLL_Message_Ack;
regs.r[1] = (int)&buff;
regs.r[2] = win;
regs.r[3] = -1;
haswin_swi(HASWIN_Send_message, ®s);
return(regs.r[2]);
}